const arr = [5, [[4, 3], 2, 1]];
function subtraction(list) {
    if (!Array.isArray(list) || list.length === 0) {
        return 0;
    }
    if (list.length === 1) {
        return list[0];
    }
    let result = Array.isArray(list[0]) ? subtraction(list[0]) : list[0];;
    for (let i = 1; i < list.length; i++) {
        const next = Array.isArray(list[i]) ? subtraction(list[i]) : list[i];
        result = result - next;
    }

    return result;
}

console.log("%c Line:21 🍣 结果", "color:#e41a6a", subtraction(arr));